package com.splant.android.smart.UILevel.Community.fragments;

import android.content.Context;
import android.view.View;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.splant.android.R;
import com.splant.android.smart.ModelLevel.PlantTypeListBean;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.BaseMultiAdapter;
import com.splant.android.smart.SystemDefinedLevel.LRecyclerview.base.SuperViewHolder;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Administrator on 2017/8/17.
 */

public class Garden_PlantTypeList_Adapter extends BaseMultiAdapter<PlantTypeListBean.PlantType> {

    public Garden_PlantTypeList_Adapter(Context context) {
        super(context);
        mContext = context;
        addItemType(0, R.layout.garden_planttypelist_item);
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder,final int position) {

        CircleImageView cImg_plantType = holder.getView(R.id.cImg_plantType);
        TextView tv_plantTypeName = holder.getView(R.id.tv_plantTypeName);

        PlantTypeListBean.PlantType plantType=getDataList().get(position);

        Glide.with(mContext)
                .load(plantType.getPlantTypeImgUrl())
                .dontAnimate()
                .placeholder(R.mipmap.garden_ic_plantimg_fail)
                .into(cImg_plantType);

        tv_plantTypeName.setText(plantType.getPlantTypeName());

        cImg_plantType.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mListener!=null)
                    mListener.onItemChick(position);
            }
        });
    }
    private onItemClickListener mListener = null;

    public void setOnItemClickListener(onItemClickListener mListener)
    {
        this.mListener=mListener;
    }

    public interface onItemClickListener {
        void onItemChick(int pos);
    }


}
